function auzTransfer(data, layerIndex) {
    data = JSON.parse(data);
    layui.use('transfer', function () {
        var transfer = layui.transfer;
        let roleId = data.id;//得到角色id
        //获取所有的权限集合
        let result = myAjax("/permission/permission/getAllPermissions", "get");
        let allPermission = result.data;//得到所有权限
        let allPermissionIds = [];
        $.each(allPermission, function (key, val) {
            allPermissionIds.push(val.id);//取得所有权限的id值
        });
        //获取角色所拥有的可用权限
        let rolePermission = data.permissions;
        let rolePermissionIds = [];
        //获取角色所拥有的可用权限id
        $.each(rolePermission, function (key, val) {
            rolePermissionIds.push(val.id);//取得所有权限的id值
        });
        //获取角色暂未拥有的可用权限id=
        // 所有权限id-已拥有的权限id=
        // 未拥有的权限id+已拥有的权限id值-已拥有的权限id
        let roleNoPermissionIds = allPermissionIds.filter(function (item) {
            return rolePermissionIds.indexOf(item) == -1;
        })
        let left = [];
        let right = [];
        console.log("allPermission");
        console.log(allPermission);
        console.log("allPermissionIds");
        console.log(allPermissionIds);
        console.log("rolePermissionIds");
        console.log(rolePermissionIds);
        console.log("roleNoPermissionIds");
        console.log(roleNoPermissionIds);
        transfer.render({
            elem: "#authority",
            title: ["所有权限", "已有权限"],
            data: allPermission,
            parseData: function (res) {
                return {
                    "value": res.id,
                    "title": res.name
                };
            },
            value: rolePermissionIds,
            showSearch: true,
            onchange: function (data, index) {
                console.log(data); //得到当前被穿梭的数据
                console.log(index); //如果数据来自左边，index 为 0，否则为 1
                let dataIds = [];
                //将移动的数据的id提取出来
                $.each(data, function (key, val) {
                    dataIds.push(val.value);
                });
                if (index == 0) {//如果数据来自左边，则将左边相同数据移除
                    // left = left.filter(function (item) {
                    //     return leftIds.indexOf(item) == -1;
                    // });
                    left = left.filter(function (item) {
                        return dataIds.indexOf(item) == -1;
                    });
                    //将移除的数据加入右边
                    $.each(dataIds, function (key, val) {
                        right.push(val);
                    });
                    right = right.filter(function (item) {
                        return rolePermissionIds.indexOf(item) == -1;
                    });
                } else if (index == 1) {//如果数据来自右边，则将右边相同数据移除
                    // right = right.filter(function (item) {
                    //     return rightIds.indexOf(item) == -1;
                    // });
                    right = right.filter(function (item) {
                        return dataIds.indexOf(item) == -1;
                    });
                    //将移动的数据加入到左边
                    $.each(dataIds, function (key, val) {
                        left.push(val);
                    });
                    left = left.filter(function (item) {
                        return roleNoPermissionIds.indexOf(item) == -1;
                    });
                }
                console.log("left");
                console.log(left);
                console.log("right");
                console.log(right);
                console.log("leftIds");
                console.log(roleNoPermissionIds);
                console.log("rightIds");
                console.log(rolePermissionIds);
            }
        });
        $("#save").click(function () {
            //获得右侧数据
            let datas = {
                "left": JSON.stringify(left),
                "right": JSON.stringify(right),
                "roleId": roleId
            }
            let result = myAjax("/permission/rolePermission/updateRolePermission", "post", datas);
            if (result) {
                layer.alert(result.message, {icon: 1},function () {
                    parent.layer.close(layerIndex);
                    parent.location.reload();
                });
            } else
                layer.alert(result.message);
        });
        $(("#cancel")).click(function () {
            parent.layer.close(layerIndex);
        });
    });
}